package group.sicher.common.constant.senum;

import lombok.Getter;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

@Getter
public enum DeliveryTypeEnum {
    YOUDUO_DELIVERY(0, "有多配送"),
    OTHER_DELIVERY(1, "其他配送");

    private int code;
    private String desc;

    private static final Map<Integer, DeliveryTypeEnum> lookupInt = new HashMap<>();
    private static final Map<String, DeliveryTypeEnum> lookupString = new HashMap<>();

    static {
        for (DeliveryTypeEnum type : EnumSet.allOf(DeliveryTypeEnum.class)) {
            lookupInt.put(type.getCode(), type);
            lookupString.put(type.getDesc(), type);
        }
    }


    DeliveryTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public static DeliveryTypeEnum find(Integer code) {
        return lookupInt.get(code);
    }

    public static DeliveryTypeEnum find(String desc) {
        return lookupString.get(desc);
    }
}
